//
//  MainViewController.m
//  Daybook
//
//  Created by dllo on 16/5/18.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "MainViewController.h"
#import "Common.h"

@interface MainViewController ()

@property (nonatomic, retain) MainView *mainView;
@property (nonatomic, retain) RightView *rightView;
@property (nonatomic, retain) UIScrollView *backgroundScrollView;

@property (nonatomic, retain) UIButton *leftButton;

@end
@implementation MainViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [tempAppDelegate.leftSlideVC setPanEnabled:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createView];
}

- (void)createView {
//    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.hidden = YES;
    self.view.backgroundColor = [UIColor brownColor];
    
//    self.backgroundScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, MAIN_WIDTH, MAIN_HEIGHT)];
//    [self.view addSubview:_backgroundScrollView];
//    self.backgroundScrollView.contentSize = CGSizeMake(MAIN_WIDTH * 2, MAIN_HEIGHT);
//    self.backgroundScrollView.contentOffset = CGPointMake(0, 0);
//    self.backgroundScrollView.bounces = NO;
//    self.backgroundScrollView.pagingEnabled = YES;
//    self.backgroundScrollView.backgroundColor = [UIColor brownColor];
    
//    self.mainView = [[MainView alloc] initWithFrame:CGRectMake(0, 0, MAIN_WIDTH, MAIN_HEIGHT)];
//    [self.backgroundScrollView addSubview:_mainView];
//    
//    self.rightView = [[RightView alloc] initWithFrame:CGRectMake(MAIN_WIDTH, 0, MAIN_WIDTH, MAIN_HEIGHT)];
//    [self.backgroundScrollView addSubview:_rightView];
    
    self.leftButton = ({
        UIButton *tempButton = [UIButton buttonWithType:UIButtonTypeCustom];
        tempButton.frame = CGRectMake(50, 116, 50, 50);
        [self.view addSubview:tempButton];
        [tempButton setTitle:@"抽屉" forState:UIControlStateNormal];
        [tempButton addTarget:self action:@selector(jumpToLeftView:) forControlEvents:UIControlEventTouchUpInside];
        tempButton.backgroundColor = [UIColor yellowColor];
        tempButton;
    });
}

- (void)jumpToLeftView:(UIButton *)button {
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    if (tempAppDelegate.leftSlideVC.closed){
        [tempAppDelegate.leftSlideVC openLeftView];
    }
    else{
        [tempAppDelegate.leftSlideVC closeLeftView];
    }
}

@end
